<?php
	if($_POST['ptfndr_hidden'] == 'Y') {
		//Form data sent
		$apiKey = $_POST['ptfndr_apiKey'];
		update_option('ptfndr_apiKey', $apiKey);

		$apiSecret = $_POST['ptfndr_apiSecret'];
		update_option('ptfndr_apiSecret', $apiSecret);

		$shelterID = $_POST['ptfndr_shelterID'];
		update_option('ptfndr_shelterID', $shelterID);

		$dbhost = $_POST['ptfndr_dbhost'];
		update_option('ptfndr_dbhost', $dbhost);

		$dbname = $_POST['ptfndr_dbname'];
		update_option('ptfndr_dbname', $dbname);

		$dbuser = $_POST['ptfndr_dbuser'];
		update_option('ptfndr_dbuser', $dbuser);

		$dbpwd = $_POST['ptfndr_dbpwd'];
        update_option('ptfndr_dbpwd', $dbpwd);

		?>
		<div class="updated"><p><strong><?php _e('Options saved.' ); ?></strong></p></div>
		<?php
	} else {
		//Normal page display
		$apiKey = get_option('ptfndr_apiKey');
		$apiSecret = get_option('ptfndr_apiSecret');
		$shelterID = get_option('ptfndr_shelterID');
		$dbhost = get_option('ptfndr_dbhost');
		$dbname = get_option('ptfndr_dbname');
		$dbuser = get_option('ptfndr_dbuser');
        $dbpwd = get_option('ptfndr_dbpwd');

	}


?>
  <div class="wrap">
        <?php    echo "<h2>" . __( 'Petfinder Pet Display Options', 'ptfndr_trdom' ) . "</h2>"; ?>

        <form name="ptfndr_form" method="post" action="<?php echo str_replace( '%7E', '~', $_SERVER['REQUEST_URI']); ?>">
            <input type="hidden" name="ptfndr_hidden" value="Y">
            <?php    echo "<h4>" . __( 'Petfinder Api Settings', 'ptfndr_trdom' ) . "</h4>"; ?>
            <p><?php _e("API-Key: " ); ?><input type="text" name="ptfndr_apiKey" value="<?php echo $apiKey; ?>" size="20"></p>
            <p><?php _e("API-Secret: " ); ?><input type="text" name="ptfndr_apiSecret" value="<?php echo $apiSecret; ?>" size="20"></p>
            <hr />
            <?php    echo "<h4>" . __( 'Other Settings', 'ptfndr_trdom' ) . "</h4>"; ?>
            <p><?php _e("ShelterID: " ); ?><input type="text" name="ptfndr_shelterID" value="<?php echo $shelterID; ?>" size="20"><?php _e(" ex: GA486" ); ?></p>
			<hr />
			<?php    echo "<h4>" . __( 'Database Settings', 'ptfndr_trdom' ) . "</h4>"; ?>
			<p><?php _e("Database host: " ); ?><input type="text" name="ptfndr_dbhost" value="<?php echo $dbhost; ?>" size="20"><?php _e(" ex: localhost" ); ?></p>
			<p><?php _e("Database name: " ); ?><input type="text" name="ptfndr_dbname" value="<?php echo $dbname; ?>" size="20"><?php _e(" ex: petfinderDB" ); ?></p>
			<p><?php _e("Database user: " ); ?><input type="text" name="ptfndr_dbuser" value="<?php echo $dbuser; ?>" size="20"><?php _e(" ex: root" ); ?></p>
			<p><?php _e("Database password: " ); ?><input type="text" name="ptfndr_dbpwd" value="<?php echo $dbpwd; ?>" size="20"><?php _e(" ex: secretpassword" ); ?></p>
        	<hr />
            <p class="submit">
            <input type="submit" name="Submit" value="<?php _e('Update Options', 'ptfndr_trdom' ) ?>" />
            </p>
        </form>
    </div>